/**
 * 上下结构的组件
 * 李沂君 2024-03-08
 */

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/**
 * 上面一个图标，下面一个文本的组件
 */
class IconTextItems extends StatefulWidget {
  final String images;
  final String texts;
  final VoidCallback tap;
  final double width;
  final double height;

  ///图文组件
  const IconTextItems({super.key, required this.images, required this.texts, required this.tap, required this.width, required this.height});

  @override
  State<IconTextItems> createState() => _IconTextItemsState();
}

class _IconTextItemsState extends State<IconTextItems> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: widget.tap,
      child: Container(
        // height: 60.h,
        // color: Colors.red,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset(
              widget.images,
              width: widget.width,
              height: widget.height,
              fit: BoxFit.cover,
            ),
            SizedBox(
              height: 10.w,
            ),
            Text(widget.texts),
          ],
        ),
      ),
    );
  }
}

/**
 * 上面一个文本，下面也是一个文本的组件
 */
class TextTextItems extends StatefulWidget {
  final String main_text;
  final String texts;
  final VoidCallback tap;

  const TextTextItems({super.key, required this.main_text, required this.texts, required this.tap});

  @override
  _TextTextItems createState() => _TextTextItems();
}

class _TextTextItems extends State<TextTextItems> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: widget.tap,
      child: Container(
        height: 60,
        // color: Colors.red,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              widget.main_text,
              style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: Color.fromRGBO(51, 51, 51, 1)),
            ),
            SizedBox(height: 10),
            Text(
              widget.texts,
              style: TextStyle(fontSize: 12, fontWeight: FontWeight.w300, color: Color.fromRGBO(51, 51, 51, 1)),
            ),
          ],
        ),
      ),
    );
  }
}

/**
 * 上面一个文本，下面是个带白框的图片
 */
class ImagesItems extends StatefulWidget {
  final String images_url;
  final String texts;
  final VoidCallback tap;
  final double width;
  final double height;

  const ImagesItems({super.key, required this.images_url, required this.texts, required this.tap, required this.width, required this.height});

  @override
  _ImagesItems createState() => _ImagesItems();
}

class _ImagesItems extends State<ImagesItems> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: widget.tap,
      child: Container(
        margin: EdgeInsets.fromLTRB(5.w, 0.w, 5.w, 0.w),
        // width: 114.w,
        // height: 50.h,
        // color: Colors.black,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Image.network(
              widget.images_url,
              width: widget.width,
              height: widget.height,
              fit: BoxFit.cover,
            ),
            SizedBox(
              height: 1,
            ),
            Container(
              alignment: Alignment.center,
              width: widget.width,
              height: 30,
              color: Colors.white,
              child: Text(
                widget.texts,
                style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w700, color: Color.fromRGBO(248, 63, 45, 1)),
              ),
            )
          ],
        ),
      ),
    );
  }
}
